home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- FILE: ArrowCDEFUtils.c
- CREATED: November 10, 1994
- AUTHOR: David Hay
- VERSION: 1.0
-
- This is a collection of utilities to make working with the ArrowCDEF a
- bit easier. See each function header for information about how to use
- a particular function.
-
- Comments and suggestions and suggestions about what would be considered
- useful utility routines for the ArrowCDEF are encouraged. I'm not sure
- what all should or could be included so let me know what you think!
-
- Copyright © 1994 David Hay
-
- CHANGE HISTORY:
- 1.0 -- Initial release
- *******************************************************************************/
-
- #include "ArrowCDEF.h"
- #include "ArrowCDEFUtils.h"
-
- struct APICData /* The data we get from the resource */
- {
- short plainPictID; /* PICT to draw for an unhilited arrow */
- short upPictID; /* PICT to draw when the up arrow is pressed */
- short downPictID; /* PICT to draw then the down arrow is pressed */
- short inactivePictID; /* PICT to draw when the arrow is inactive */
- };
-
- typedef struct APICData APICData;
- typedef APICData *APICPtr, **APICHandle;
-
-
- /*******************************************************************************
- * FUNCTION: SetArrowAPIC
- *
- * INPUT: ControlHandle arrow -- the arrow to change the APIC resource of
- * short apicID -- the new APIC resource number
- * Boolean redraw -- should the control be redrawn?
- * RETURNS: Nothing.
- *
- * DESCRIPTION: Changes the pictures of an arrow to the pictures defined by an
- * APIC resource given by apicID.
- *******************************************************************************/
- void SetArrowAPIC( ControlHandle arrow, short apicID, Boolean redraw )
- {
- APICHandle apic;
-
- apic = (APICHandle) GetResource( kArrowResType, apicID );
- SetArrowPictures( arrow, (**apic).plainPictID, (**apic).upPictID,
- (**apic).downPictID, (**apic).inactivePictID, redraw );
- ReleaseResource( (Handle) apic );
- }
-
- /*******************************************************************************
- * FUNCTION: SetArrowPictures
- *
- * INPUT: ControlHandle arrow -- the arrow to change the pictures of
- * short plainPICT -- Pict for drawing the arrow unhilted
- * short upPICT -- Pict for arrow with the up button pressed
- * short downPICT -- Pict for arrow with the down button pressed
- * short inactivePICT -- Pict for drawing the arrow as inactive
- * Boolean redraw -- should we redraw the control?
- * RETURNS: Nothing.
- *
- * DESCRIPTION: Changes the pictures of an arrow to the pictures given by the
- * individual ID numbers. If redraw is true, the control is
- * invalidated so that it gets redrawn during the next update event.
- *******************************************************************************/
- void SetArrowPictures( ControlHandle arrow, short plainPICT, short upPICT,
- short downPICT, short inactivePICT, Boolean redraw )
- {
- APICHandle apic;
- Rect arrowRect;
- GrafPtr savePort;
- SignedByte hState;
-
- apic = (APICHandle) (**arrow).contrlData; /* update the pict resources */
- (**apic).plainPictID = plainPICT; /* within the control's data */
- (**apic).upPictID = upPICT; /* field with the new values */
- (**apic).downPictID = downPICT; /* passed in as parameters */
- (**apic).inactivePictID = inactivePICT;
-
- if ( redraw ) /* We're to redraw the control */
- {
- GetPort( &savePort );
- hState = HGetState( (Handle) arrow );
- SetPort( (**arrow).contrlOwner );
- arrowRect = (**arrow).contrlRect;
- InvalRect( &arrowRect );
- SetPort( savePort );
- HSetState( (Handle) arrow, hState );
- }
- }